package com.yx.filesystem.storage;

import java.io.File;

public final class SpaceChecker {
	private static long totalSpace=0;	
	private static long freeSpace=0;
	private static long usedSpace=0;
	private static boolean spaceFull=true;
	
	public static void check(){
		String path=Archive.FILE_SAVE_ROOT_PATH.substring(0, Archive.FILE_SAVE_ROOT_PATH.indexOf(":")+1);
		File file=new File(path);
		totalSpace=file.getTotalSpace();
		freeSpace=file.getFreeSpace();
		usedSpace=file.getTotalSpace()-file.getFreeSpace();
		if(totalSpace*0.15>freeSpace){
			spaceFull=true;
		}else{
			spaceFull=false;
		}
	}
	public static long getTotalSpace() {
		return totalSpace;
	}
	public static long getFreeSpace() {
		return freeSpace;
	}
	public static long getUsedSpace() {
		return usedSpace;
	}
	public static boolean isSpaceFull() {
		return spaceFull;
	}
	public static void main(String[] args) {
		System.out.println(Archive.FILE_SAVE_ROOT_PATH);
		SpaceChecker.check();
		System.out.println(SpaceChecker.getTotalSpace());
		System.out.println(SpaceChecker.getUsedSpace());
		System.out.println(SpaceChecker.getFreeSpace());
		System.out.println(SpaceChecker.isSpaceFull());
	}
}
